package com.cmw.socket.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.Closeable;
import java.io.IOException;
import java.util.Arrays;

/**
 * 流关闭工具类
 * @date 2020-06-20 18:48
 * @author chengmingwei
 */
@Slf4j
public class CloseUtils {

    /**
     * 关闭流
     * @param closeables
     */
  public static void close(Closeable... closeables){
    if(null == closeables || closeables.length == 0){
        log.error("参数：closeables 为空，不需要关闭!");
        return;
    }
    Arrays.asList(closeables).stream().forEach(closeable -> {
          try {
              closeable.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
    });
  }
}
